<?php

/**
 * This is the model class for table "pump".
 *
 * The followings are the available columns in table 'pump':
 * @property integer $id
 * @property integer $no
 * @property string $make
 * @property string $property_supported_guard_pipe
 * @property integer $distance_from_street_curb
 * @property integer $distance_from_adjacent_building
 * @property integer $emergency_pump_shutoff_provided
 * @property string $type
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class Pump extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Pump the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	const a = "Manual";
const b ="Automatic";
public function getType(){
return array(
self::a=>"Manual",
self::b=>"Automatic"
);


}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pump';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('no, distance_from_street_curb, distance_from_adjacent_building, emergency_pump_shutoff_provided, inspection_id', 'numerical', 'integerOnly'=>true),
			array('type', 'length', 'max'=>9),
			array('make, property_supported_guard_pipe', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, no, make, property_supported_guard_pipe, distance_from_street_curb, distance_from_adjacent_building, emergency_pump_shutoff_provided, type, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'no' => 'No',
			'make' => 'Make',
			'property_supported_guard_pipe' => 'Property Supported Guard Pipe',
			'distance_from_street_curb' => 'Distance From Street Curb',
			'distance_from_adjacent_building' => 'Distance From Adjacent Building',
			'emergency_pump_shutoff_provided' => 'Emergency Pump Shutoff Provided',
			'type' => 'Type',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('no',$this->no);
		$criteria->compare('make',$this->make,true);
		$criteria->compare('property_supported_guard_pipe',$this->property_supported_guard_pipe,true);
		$criteria->compare('distance_from_street_curb',$this->distance_from_street_curb);
		$criteria->compare('distance_from_adjacent_building',$this->distance_from_adjacent_building);
		$criteria->compare('emergency_pump_shutoff_provided',$this->emergency_pump_shutoff_provided);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}